﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Pointandclick;


namespace Pointandclick.ScreenManagement
{
    class MainMenuScreen : MenuScreen
    {
        ///<summary>
        /// Creates the menu screen
        /// </summary>
        /// <param name="manager">the manager which this screen belongs to</param>
        public MainMenuScreen(ScreenManager manager)
        {
            this.Manager = manager;
            LoadContent();
            TextMenuButton startButton = new TextMenuButton("Start", Font);
            TextMenuButton exitButton = new TextMenuButton("Exit", Font);
            TextMenuButton testButton = new TextMenuButton("Speed Test", Font);
            this.Options = new List<MenuElement> { startButton, testButton, exitButton };
            base.CenterElements(new Rectangle(0, 0, Manager.Window.ClientBounds.Width, Manager.Window.ClientBounds.Height), Options[0].Rectangle.Height);
        }

        protected override void LoadContent()
        {
            Font = Manager.Content.Load<SpriteFont>("testFont");
            Background = Manager.Content.Load<Texture2D>("background");

        }

        public override void Update(GameTime gameTime)
        {
            foreach (MenuElement option in Options)
            {
                if (option.ClickedOn())
                    if (option.Label == "Start")
                        Manager.ChangeScreen(new TestingScreen(Manager));
                    else if (option.Label == "Speed Test")
                        Manager.ChangeScreen(new SpeedTestScreen(Manager));
                    else
                        Manager.PopUp(new ExitPopUp(Manager));
            }
        }

        public override void Draw(SpriteBatch spriteBatch, Color color)
        {
            spriteBatch.Draw(Background, Vector2.Zero, color);
            base.Draw(spriteBatch, color);
        }
    }
}
